package com.xinshujia.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.xinshujia.configuration.adapter.DateAdapter;
import com.xinshujia.configuration.adapter.LocalDateAdapter;
import com.xinshujia.configuration.adapter.LocalDateTimeAdapter;
import com.xinshujia.configuration.adapter.TimestampAdapter;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * *************************************
 * *   @author: 野狼上校               **
 * *   @since: 2024-07-16 11:53       **
 * *   @version: 1.0                  **
 * *************************************
 * <p>
 */
public class GsonUtil {
    public static Gson googleGson(){
        return new GsonBuilder()
                .registerTypeAdapter(Date.class, new DateAdapter())
                .registerTypeAdapter(LocalDate.class, new LocalDateAdapter())
                .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeAdapter())
                .registerTypeAdapter(Timestamp.class, new TimestampAdapter())
                .create();
    }
}
